home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / ABUSESRC.ZIP / AbuseSrc / macabuse / src / idle.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-20  |  1.9 KB  |  97 lines

  1. #include "idle.hpp"
  2. #include "jwindow.hpp"
  3.  
  4. extern window_manager *eh;
  5.  
  6. idle_manager *idle_man=0;
  7.  
  8. idle_manager::~idle_manager() 
  9.   idle_reset(); 
  10.   int i;
  11.   for (i=0;i<total_wait_frames;i++)
  12.     delete wait_cursors[i];
  13. }
  14.  
  15. idle_manager::idle_manager()
  16. {
  17.   cursor_frame_on=-1;
  18.   first=last=0;
  19.   
  20.   bFILE *fp=open_file("art/wait.spe","rb");
  21.   char name[20];
  22.   spec_directory sd(fp);
  23.  
  24.   for (int i=0;i<total_wait_frames;i++)
  25.   {
  26.     sprintf(name,"watch_%d",i+1);
  27.     spec_entry *se=sd.find(name);
  28.     if (!se)
  29.     {
  30.       lbreak("could not find %s in %s\n",name,"art/wait.spe");
  31.       exit(0);
  32.     }
  33.  
  34.     wait_cursors[i]=new image(se,fp);
  35.   }
  36.   delete fp;
  37. }
  38.  
  39. void idle_manager::idle_reset()
  40. {
  41.   last_idle.get_time();
  42.   if (cursor_frame_on!=-1)
  43.   {
  44.     eh->set_mouse_shape(old,old_cx,old_cy);
  45.     cursor_frame_on=-1;
  46.  
  47.     while (first)
  48.     {
  49.       eh->push_event(first->ev);
  50.       event_holder *l=first;
  51.       first=first->next;
  52.       delete l;
  53.     }
  54.     last=0;
  55.   }
  56. }
  57.  
  58. void idle_manager::idle()
  59. {
  60.   time_marker now;
  61.  
  62.   if (cursor_frame_on==-1)
  63.   {
  64.     if (now.diff_time(&last_idle)>0.5)
  65.     {
  66.       old=eh->eh->mouse->mouse_sprite()->visual->copy();
  67.       old_cx=eh->eh->mouse->center_x();
  68.       old_cy=eh->eh->mouse->center_y();
  69.       cursor_frame_on=0;
  70.       eh->set_mouse_shape(wait_cursors[cursor_frame_on]->copy(),0,0);
  71.       eh->flush_screen();
  72.     }
  73.   } else if (now.diff_time(&last_animate)>0.1)
  74.   {
  75.     cursor_frame_on++;
  76.     if (cursor_frame_on>=total_wait_frames)
  77.       cursor_frame_on=0;
  78.  
  79.     eh->set_mouse_shape(wait_cursors[cursor_frame_on]->copy(),0,0);
  80.     last_animate.get_time();
  81.       eh->flush_screen();
  82.   } else
  83.   {
  84.     event ev;
  85.     while (eh->event_waiting())
  86.     {
  87.       eh->get_event(ev);
  88.       if (ev.type!=EV_MOUSE_MOVE)
  89.         que_event(ev);
  90.       eh->flush_screen();
  91.     }
  92.   }
  93. }
  94.  
  95.  
  96.